(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 9.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[      9676,        337]
NotebookOptionsPosition[      7310,        248]
NotebookOutlinePosition[      8100,        278]
CellTagsIndexPosition[      7976,        272]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
 RowBox[{
  RowBox[{"PrependTo", "[", 
   RowBox[{"$Path", ",", 
    RowBox[{
     RowBox[{"NotebookDirectory", "[", "]"}], "//", "ParentDirectory"}]}], 
   "]"}], ";"}]], "Input"],

Cell[CellGroupData[{

Cell["Install MSFTP", "Section"],

Cell[BoxData[
 RowBox[{"If", "[", 
  RowBox[{
   RowBox[{
    RowBox[{"FindFile", "[", "\"\<MSFTP`\>\"", "]"}], "===", "$Failed"}], ",",
    " ", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
    "Import", "[", 
     "\"\<http://packageinstaller.googlecode.com/hg/PackageInstaller/\
PackageInstaller.m\>\"", "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{"PackageInstaller`InstallPackage", "[", 
     RowBox[{
     "\"\<http://msftp.googlecode.com/hg\>\"", ",", "\"\<MSFTP.zip\>\""}], 
     "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]], "Input"],

Cell[BoxData[
 RowBox[{
  RowBox[{"Needs", "[", "\"\<MSFTP`\>\"", "]"}], ";"}]], "Input"],

Cell["\<\
To open this notebook:
NotebookOpen@FileNameJoin[{ParentDirectory@DirectoryName@FindFile[\
\[OpenCurlyDoubleQuote]MSFTP`\[CloseCurlyDoubleQuote]],\
\[CloseCurlyDoubleQuote]MSFTP.nb\[CloseCurlyDoubleQuote]}]\
\>", "Text"],

Cell["\<\
Uninstall by
UninstallPackage[\"MSFTP`\"] // ReleaseHold\
\>", "Text"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Inspect package", "Section"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "MSFTPPut"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"MSFTPPut[fileordirectory, \\\"UserName\\\" -> \\\"rolfm\\\", \
\\\"HostName\\\" -> \\\"sftpserver.company.com\\\", \
\\n\\\"Password\\\"->\\\"secret\\\"] uploads fileordirectory. \
MSFTPPut[fileordir, remotedir] uploads to remotedir.\\nThe password can be \
either given in clear text, or as a list of integers as returned by \
PassEncode[\\\"mypassword\\\"].\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3568977253-4287438"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "MSFTPGet"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"MSFTPGet[remotefile, localdir] transfers remotefile to \
localdir.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3568977253-4287438"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"Options", "[", "MSFTPPut", "]"}], "//", "InputForm"}]], "Input"],

Cell["\<\
{\"HostName\" -> \"test.gluonvision.de\", \"Password\" -> \"secret\", 
 \"Port\" -> 22, \"StrictHostKeyChecking\" -> \"no\", 
 \"PreferredAuthentications\" -> \"password\", 
 \"UserName\" :> $UserName, Print -> True}\
\>", "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "PassEncode"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"PassEncode[secret] encodes the password secret for the \
$MachineID of the current computer. \\nThe resulting list can be given as an \
encoded password setting for the option Password of MSFTPPut and \
MSFTPGet.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3568980277-4287438"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"PassEncode", "[", "\"\<p4ssW.rdD\>\"", "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
  "40", ",", "42", ",", "33", ",", "49", ",", "72", ",", "33", ",", "42", ",",
    "41", ",", "57", ",", "50", ",", "125", ",", "10", ",", "64", ",", "120", 
   ",", "122", ",", "106", ",", "124", ",", "63", ",", "120", ",", "88", ",", 
   "72", ",", "97", ",", "47", ",", "87", ",", "117", ",", "178", ",", "83", 
   ",", "81", ",", "119", ",", "165", ",", "50", ",", "121", ",", "60", ",", 
   "91"}], "}"}]], "Output"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\<\
Tests (for the purpose of testing do outside this notebook 
SetOptions[MSFTPPut, \[OpenCurlyDoubleQuote]Password\[CloseCurlyDoubleQuote] \
-> ...];\
\>", "Section"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"SetOptions", "[", 
  RowBox[{"MSFTPPut", ",", " ", 
   RowBox[{"\"\<Password\>\"", "\[Rule]", "\"\<superscret\>\""}], ",", 
   RowBox[{"Print", "\[Rule]", "True"}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"\<\"HostName\"\>", "\[Rule]", "\<\"test.gluonvision.de\"\>"}], 
   ",", 
   RowBox[{"\<\"Password\"\>", "\[Rule]", "\<\"superscret\"\>"}], ",", 
   RowBox[{"\<\"Port\"\>", "\[Rule]", "22"}], ",", 
   RowBox[{"\<\"StrictHostKeyChecking\"\>", "\[Rule]", "\<\"no\"\>"}], ",", 
   RowBox[{"\<\"PreferredAuthentications\"\>", 
    "\[Rule]", "\<\"password\"\>"}], ",", 
   RowBox[{"\<\"UserName\"\>", "\[RuleDelayed]", "$UserName"}], ",", 
   RowBox[{"Print", "\[Rule]", "True"}]}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell["\<\
put a directory with all content into the directory on the server:\
\>", "Subsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"If", "[", 
  RowBox[{
   RowBox[{"$UserName", "===", "\"\<Rolf Mertig\>\""}], ",", 
   "\[IndentingNewLine]", 
   RowBox[{"MSFTPPut", "[", 
    RowBox[{
     RowBox[{
      RowBox[{"NotebookDirectory", "[", "]"}], "//", "ParentDirectory"}], 
     ",", "\"\<MSFTP2\>\"", ",", " ", 
     RowBox[{"\"\<UserName\>\"", " ", "\[Rule]", " ", "\"\<rolfm\>\""}], ",", 
     RowBox[{"\"\<HostName\>\"", "\[Rule]", "\"\<test.gluonvision.de\>\""}]}],
     "]"}]}], "]"}]], "Input"],

Cell[BoxData["\<\"G:\\\\workspace5\\\\MSFTP\"\>"], "Output"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\<\
put a single file to the home directory of user rolfm on the server:\
\>", "Subsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"If", "[", 
  RowBox[{
   RowBox[{"$UserName", "===", "\"\<Rolf Mertig\>\""}], ",", 
   "\[IndentingNewLine]", 
   RowBox[{"MSFTPPut", "[", 
    RowBox[{
     RowBox[{"ToFileName", "[", 
      RowBox[{"\"\<FileName\>\"", "/.", "\[VeryThinSpace]", 
       RowBox[{"NotebookInformation", "[", 
        RowBox[{"InputNotebook", "[", "]"}], "]"}]}], "]"}], ",", 
     "\"\<MSFTP2\>\"", ",", 
     RowBox[{"\"\<UserName\>\"", "\[Rule]", "\"\<rolfm\>\""}], ",", 
     RowBox[{"\"\<HostName\>\"", "\[Rule]", "\"\<test.gluonvision.de\>\""}]}],
     "]"}]}], "]"}]], "Input"],

Cell[BoxData["\<\"G:\\\\workspace5\\\\MSFTP\\\\MSFTP\\\\MSFTP.nb\"\>"], \
"Output"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["Create a remote directory (test)  and upload a file to it", "Subsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"MSFTPPut", "[", 
  RowBox[{
   RowBox[{"ToFileName", "[", 
    RowBox[{"\"\<FileName\>\"", "/.", "\[VeryThinSpace]", 
     RowBox[{"NotebookInformation", "[", 
      RowBox[{"InputNotebook", "[", "]"}], "]"}]}], "]"}], ",", 
   "\"\<test\>\"", ",", " ", 
   RowBox[{"\"\<UserName\>\"", " ", "\[Rule]", " ", "\"\<rolfm\>\""}], ",", 
   RowBox[{"\"\<HostName\>\"", "\[Rule]", "\"\<test.gluonvision.de\>\""}]}], 
  "]"}]], "Input"],

Cell[BoxData["\<\"G:\\\\workspace5\\\\MSFTP\\\\MSFTP\\\\MSFTP.nb\"\>"], \
"Output"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
},
Editable->True,
WindowSize->{1643, 751},
WindowMargins->{{106, Automatic}, {Automatic, 8}},
ShowSelection->True,
Magnification:>1.5 Inherited,
FrontEndVersion->"9.0 for Microsoft Windows (64-bit) (January 25, 2013)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{
 "Info3568977253-4287438"->{
  Cell[1919, 74, 463, 7, 122, "Print",
   CellTags->"Info3568977253-4287438"],
  Cell[2473, 89, 170, 3, 62, "Print",
   CellTags->"Info3568977253-4287438"]},
 "Info3568980277-4287438"->{
  Cell[3117, 114, 316, 5, 91, "Print",
   CellTags->"Info3568980277-4287438"]}
 }
*)
(*CellTagsIndex
CellTagsIndex->{
 {"Info3568977253-4287438", 7686, 261},
 {"Info3568980277-4287438", 7873, 266}
 }
*)
(*NotebookFileOutline
Notebook[{
Cell[557, 20, 194, 6, 45, "Input"],
Cell[CellGroupData[{
Cell[776, 30, 32, 0, 130, "Section"],
Cell[811, 32, 550, 14, 133, "Input"],
Cell[1364, 48, 89, 2, 45, "Input"],
Cell[1456, 52, 230, 5, 74, "Text"],
Cell[1689, 59, 80, 3, 74, "Text"]
}, Open  ]],
Cell[CellGroupData[{
Cell[1806, 67, 34, 0, 130, "Section"],
Cell[CellGroupData[{
Cell[1865, 71, 51, 1, 45, "Input"],
Cell[1919, 74, 463, 7, 122, "Print",
 CellTags->"Info3568977253-4287438"]
}, Open  ]],
Cell[CellGroupData[{
Cell[2419, 86, 51, 1, 44, "Input"],
Cell[2473, 89, 170, 3, 62, "Print",
 CellTags->"Info3568977253-4287438"]
}, Open  ]],
Cell[CellGroupData[{
Cell[2680, 97, 99, 2, 44, "Input"],
Cell[2782, 101, 242, 5, 131, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[3061, 111, 53, 1, 44, "Input"],
Cell[3117, 114, 316, 5, 91, "Print",
 CellTags->"Info3568980277-4287438"]
}, Open  ]],
Cell[CellGroupData[{
Cell[3470, 124, 79, 1, 44, "Input"],
Cell[3552, 127, 461, 8, 71, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[4062, 141, 174, 4, 192, "Section"],
Cell[CellGroupData[{
Cell[4261, 149, 207, 4, 44, "Input"],
Cell[4471, 155, 547, 11, 71, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[5055, 171, 96, 2, 71, "Subsection"],
Cell[CellGroupData[{
Cell[5176, 177, 493, 12, 101, "Input"],
Cell[5672, 191, 60, 0, 43, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[5781, 197, 98, 2, 71, "Subsection"],
Cell[CellGroupData[{
Cell[5904, 203, 589, 14, 101, "Input"],
Cell[6496, 219, 83, 1, 43, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[6628, 226, 79, 0, 71, "Subsection"],
Cell[CellGroupData[{
Cell[6732, 230, 452, 10, 73, "Input"],
Cell[7187, 242, 83, 1, 43, "Output"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
